package cn.edu.zafu.bigdata.wupeng;
// Book 类
class Book2 {
    // 字段
    private String title;
    private String author;
    private double price;

    // 带参构造器
    public Book2(String title, String author, double price) {
        this.title = title;
        this.author = author;
        this.price = price;
    }

    // 重写 toString 方法
    @Override
    public String toString() {
        return "Book[title=" + title + ", author=" + author + ", price=" + price + "]";
    }

    // Getter 和 Setter 方法（如果需要）
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }
}

// 测试类
public class TestBook {
    public static void main(String[] args) {
        // 创建 Book 对象
        Book2 book1 = new Book2("Java Programming", "John Doe", 29.99);
        Book2 book2 = new Book2("Learning Python", "Jane Smith", 19.99);
        Book2 book3 = new Book2("Data Structures and Algorithms", "Alice Johnson", 39.99);

        // 打印 Book 对象的信息
        System.out.println(book1);
        System.out.println(book2);
        System.out.println(book3);
    }
}